home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.04 Apr 95 / Performance / Fractal 8 / Fractal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-13  |  3.2 KB  |  126 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Fractal.h
  3.  
  4.     Used to build:    “Fractal 8”
  5.     
  6.     Written by:        Jim Cathey            July 1985
  7.                     Eric Traut            November 1994
  8.  
  9.     Description:
  10.         See comments in the file “FractalMain.c” for more
  11.         information.
  12. */
  13.  
  14. #include <QDOffscreen.h>
  15.  
  16. /* Menu information */
  17. enum {
  18.     kMenuBarID            = 128,
  19.     kAppleMenuID        = 128,
  20.     kAboutBoxItem        = 1,
  21.     kFileMenuID            = 129,
  22.     kNewFractalItem        = 1,
  23.     kQuitItem            = 3,
  24.     kEditMenuID            = 130,
  25.     kOptionsMenuID        = 131,
  26.     kSetupItem            = 1,
  27.     kContinuousItem        = 3,
  28.     kMorphItem            = 4,
  29.     kDrawSurfaceItem    = 5
  30. };
  31.  
  32. /* Window, dialog, and alert constants */
  33. enum {
  34.     kMainWindowID            = 260,
  35.     kAboutBox1DialogID        = 256,
  36.     kAboutBoxOKButtonID        = 1,
  37.     kAboutBoxMoreButtonID    = 2,
  38.     kAboutBox2DialogID        = 257,
  39.     kFatalErrorAlertID        = 128
  40. };
  41.  
  42. /* Setup dialog constants */
  43. enum {
  44.     kSetUpDialogID            = 258,
  45.     kSetUpOKButtonID        = 1,
  46.     kSetUpCancelButtonID    = 2,
  47.     kSetUpLevelID            = 4,
  48.     kSetUpMtnButtonID        = 5,
  49.     kSetUpHillsButtonID        = 6,
  50.     kSetUpWaterButtonID        = 7
  51. };
  52.  
  53. /* Style and level constants */
  54. enum {
  55.     kStyleMountains            = kSetUpMtnButtonID,
  56.     kStyleHills                = kSetUpHillsButtonID,
  57.     kStyleWater                = kSetUpWaterButtonID,
  58.     kMaxLevel                = 7,
  59.     kDefaultStyle            = kStyleWater,
  60.     kDefaultLevel            = 6
  61. };
  62.  
  63. enum {
  64.     kMaxXPoint                = ((1 << kMaxLevel) + 1) + 1,
  65.     kMaxYPoint                = ((1 << (kMaxLevel - 1)) + 1) + 1
  66. };
  67.  
  68. /* Screen constants */
  69. enum {
  70.     kNewScreenX                = 630,
  71.     kNewScreenY                = 434,
  72.     kScaleShift                = 5,
  73.     kScreenBoundaryBits        = 5,
  74.     kWindowTitleHeight        = 16,
  75.     kTotalGrays                = 256
  76. };
  77.  
  78. enum {
  79.     kXOrigin                = 40,
  80.     kYOrigin                = 108,
  81.     kYMountainOrigin        = 330
  82. };
  83.  
  84. enum {
  85.     kShadeMapSize        = 256,
  86.     kVectorBaseSize        = 16
  87. };
  88.  
  89. /* Types used in fractal */
  90. struct ThreePoint {
  91.     short        x;
  92.     short        y;
  93.     short        z;
  94. };
  95. typedef struct ThreePoint ThreePoint;
  96.  
  97. /* Global variables used in multiple files */
  98. extern short (*gOldPointArray)[kMaxXPoint][kMaxYPoint];        
  99.                                             /* The array of points to be subdivided. */
  100. extern short (*gNewPointArray)[kMaxXPoint][kMaxYPoint];        
  101.                                             /* The array of points to be subdivided. */
  102. extern ThreePoint (*gPlotPointArray)[2 * kMaxXPoint][2 * kMaxYPoint];
  103.                                             /* The array of points to be subdivided */
  104. extern short gContourType;                    /* Contour type */
  105. extern short gContourLevel;                    /* Level of detail */
  106. extern short gMainWindowHeight;                /* Height of main window */
  107. extern short gMainWindowWidth;                /* Width of main window */
  108. extern long gMicrosecondCount;                /* Total time spent calculating and drawing */
  109. extern long gTotalFractals;                    /* Total fractal count */
  110. extern Boolean gFractalChanged;                /* Should this screen update be counted? */
  111. extern GWorldPtr gOffscreenGWorld;            /* GWorld for faster drawing */
  112. extern PixMapHandle    gOffscreenPixMap;        /* Offscreen PixMap */
  113. extern WindowPtr gMainWindow;                /* Our one window */
  114. extern float gMorphAmount;                    /* Percent of morph complete */
  115. extern float gMorphAmountNeg;
  116. extern Boolean gContinuousRedraw;            /* Continuously redraw fractal */
  117. extern Boolean gMorphFractal;                /* Morph or not morph */
  118. extern unsigned short gShadeMap[kShadeMapSize];
  119.  
  120. void CalcSurface(unsigned short level);
  121. void PlotData(Boolean plotSurface);
  122. void SetBlitBuffer(unsigned char *blitData, Rect *blitBounds, short blitRowBytes);
  123. void FillTriangle(long vertex1H, long vertex1V, long vertex2H, long vertex2V, long vertex3H, long vertex3V, unsigned char color);
  124.  
  125.  
  126.